object VectorOperations
{
	def main() : Unit = { println(new VectorTester().Test()); }
}

class VectorTester
{
	
	def Test() : String =
	{
		var oV1 : Vector;
		var oV2 : Vector;
		var oV3 : Vector;
		var szRes : String;
		oV1 = new Vector().New(3);
		oV2 = new Vector().New(3);
		oV3 = new Vector().New(3);
		if(!(oV1.SetValue(0, 1) && oV1.SetValue(1, 2) && oV1.SetValue(2, 3) && oV2.SetValue(0, 4) && oV2.SetValue(1, 5) && oV2.SetValue(2, 6) ))
		{ szRes = "Error"; }
		else
		{ 
			oV3 = oV3.VectorProduct(oV1, oV2);
			szRes = "Scalar Product : " + oV1.ScalarProduct(oV2) + " || Vector Product : " + oV3.ToString();
		}
		return szRes;
	}
	
}


class Vector
{
	var nSize : Int;
	var nColArray : Int[];
	
	
	def GetSize() : Int = { return nSize; }
	def GetColArray() : Int[] = { return nColArray; }
	
	
	def New(nDim : Int) : Vector =
	{
		if(nDim < 0) { println("Vector dimension must be positive."); nSize = 0; }
		else
		{
			nSize = nDim;
			nColArray = new Int[nSize];
		}
		return this;
	}


	def SetValue(nIndex : Int, nVal : Int) : Bool =
	{ 
		var bOk : Bool;
		var nMaxIndex : Int;
		bOk = false;
		if(nIndex < nSize && !(nIndex < 0)) { nColArray[nIndex] = nVal; bOk = true; }
		else
		{
			nMaxIndex = nSize - 1;
			println("The index you specified is incorrect. Please select one between 0 and " + nMaxIndex + ".");
		}
		return bOk;
	}


	def ScalarProduct(oVector : Vector) : Int =
	{
		var nResult : Int;
		var i : Int;
		var nColArray2 : Int[];
		nResult = 0;
		if(!(nSize == oVector.GetSize()))
		{ println("Scalar product is undefined. Vector dimensions are different."); }
		else
		{
			nColArray2 = oVector.GetColArray();
			i = 0;
			while(i < nSize) { nResult = nResult + nColArray[i] * nColArray2[i]; i = i + 1; }
		}
		return nResult;
	}
	
	
	def VectorProduct(oVector1 : Vector, oVector2 : Vector) : Vector =
	{
		var nColArray1 : Int[];
		var nColArray2 : Int[];
		var nMinusOne : Int;
		nMinusOne = 0 - 1;
		if(!(oVector1.GetSize() == 3 && oVector2.GetSize() == 3)) { println("Vector product is undefined. Vector dimensions should be equal to 3."); }
		else
		{
			nColArray1 = oVector1.GetColArray();
			nColArray2 = oVector2.GetColArray();
			nColArray[0] = (nColArray1[0] * nColArray2[1]) - (nColArray1[1] * nColArray2[0]);
			nColArray[1] = ((nColArray1[0] * nColArray2[2]) - (nColArray1[2] * nColArray2[0])) * nMinusOne;
			nColArray[2] = (nColArray1[1] * nColArray2[2]) - (nColArray1[2] * nColArray2[1]);
		}
		return this;
	}
	
	
	def ToString() : String =
	{ 
		var szRes : String;
		var i : Int;
		szRes = "(";
		i = 0;
		while(i < nSize)
		{ 
			if(i + 1 == nSize) { szRes = szRes + nColArray[i]; }
			else { szRes = szRes + nColArray[i] + ", "; }
			i = i + 1;
		}
		szRes = szRes + ")";
		return szRes;
	}
}